this.BX=this.BX||{};(function(e,t,s,i,r,n,a,o){"use strict";var l,u;var c=o.Reflection.namespace("BX");var h=function(){function e(t){babelHelpers.classCallCheck(this,e);t=t||{};this.options=t;this.renderTo=t.renderTo;this.buttonPanel=c.UI.ButtonPanel||null;this.layout={container:null};this.component=t.component?t.component:null;this.actionSave=t.actionSave||e.ACTION_SAVE;this.actionDelete=t.actionDelete||e.ACTION_DELETE;this.actionLoad=t.actionLoad||e.ACTION_LOAD;this.mode=t.mode||e.MODE;this.openPopupEvent=t.openPopupEvent?t.openPopupEvent:null;this.popupContainer=t.popupContainer?t.popupContainer:null;this.additionalSaveParams=t.additionalSaveParams?t.additionalSaveParams:null;this.loadParams=t.loadParams?t.loadParams:null;this.loader=null;this.timer=null;this.initData();if(t.userGroups){this.userGroups=t.userGroups}if(t.accessRights){this.accessRights=t.accessRights}this.isRequested=false;this.loadData();this.bindEvents()}babelHelpers.createClass(e,[{key:"bindEvents",value:function e(){n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:updateRole",this.updateRole.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:selectAccessItems",this.updateAccessVariationRight.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:accessOn",this.updateAccessRight.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:accessOff",this.updateAccessRight.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:update",this.adjustButtonPanel.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:addRole",this.addUserGroup.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:addRole",this.addRoleColumn.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:copyRole",this.addRoleColumn.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:copyRole",this.addUserGroup.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:removeRole",this.removeRoleColumn.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:removeRole",this.adjustButtonPanel.bind(this));n.EventEmitter.subscribe("BX.Main.SelectorV2:onGetEntityTypes",this.onGetEntityTypes.bind(this))}},{key:"initData",value:function e(){this.accessRights=[];this.userGroups=[];this.accessRightsSections=[];this.headSection=null;this.members=[];this.columns=[]}},{key:"fireEventReset",value:function e(){n.EventEmitter.emit("BX.UI.AccessRights:reset",this)}},{key:"fireEventRefresh",value:function e(){n.EventEmitter.emit("BX.UI.AccessRights:refresh",this)}},{key:"getButtonPanel",value:function e(){return this.buttonPanel}},{key:"showNotification",value:function e(t){c.UI.Notification.Center.notify({content:t,position:"top-right",autoHideDelay:3e3})}},{key:"sendActionRequest",value:function e(){var t=this;if(this.isRequested){return}this.isRequested=true;n.EventEmitter.emit(this,"onBeforeSave",this);this.timer=setTimeout((function(){t.blockGrid()}),1e3);var s=false;var i=[];for(var r=0;r<this.userGroups.length;r++){if(o.Text.toNumber(this.userGroups[r].id)===0){s=true}i.push({accessCodes:this.userGroups[r].accessCodes,id:this.userGroups[r].id,title:this.userGroups[r].title,type:this.userGroups[r].type,accessRights:this.userGroups[r].accessRights})}c.ajax.runComponentAction(this.component,this.actionSave,{mode:this.mode,data:{userGroups:i,parameters:this.additionalSaveParams}}).then((function(){if(s){t.reloadGrid()}t.isRequested=false;t.showNotification(o.Loc.getMessage("JS_UI_ACCESSRIGHTS_STTINGS_HAVE_BEEN_SAVED"));t.unBlockGrid();t.fireEventRefresh();setTimeout((function(){t.adjustButtonPanel()}));clearTimeout(t.timer);var e=t.buttonPanel.getContainer().querySelector(".ui-btn-wait");o.Dom.removeClass(e,"ui-btn-wait")}),(function(){t.isRequested=false;t.showNotification("Error message");t.unBlockGrid();clearTimeout(t.timer);var e=t.buttonPanel.getContainer().querySelector(".ui-btn-wait");o.Dom.removeClass(e,"ui-btn-wait")}));n.EventEmitter.emit("BX.UI.AccessRights:preservation",this)}},{key:"lock",value:function e(){o.Dom.addClass(this.getMainContainer(),"--lock")}},{key:"unlock",value:function e(){o.Dom.removeClass(this.getMainContainer(),"--lock")}},{key:"deleteActionRequest",value:function e(t){var s=this;if(this.isRequested){return}this.isRequested=true;this.timer=setTimeout((function(){s.blockGrid()}),1e3);c.ajax.runComponentAction(this.component,this.actionDelete,{mode:this.mode,data:{roleId:t}}).then((function(){s.isRequested=false;s.showNotification(o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ROLE_REMOVE"));s.unBlockGrid();clearTimeout(s.timer)}),(function(){s.isRequested=false;s.showNotification("Error message");s.unBlockGrid();clearTimeout(s.timer)}))}},{key:"reloadGrid",value:function e(){var t=this;this.initData();c.ajax.runComponentAction(this.component,this.actionLoad,{mode:this.mode,data:{parameters:this.loadParams}}).then((function(e){if(e.data["ACCESS_RIGHTS"]&&e.data["USER_GROUPS"]){t.accessRights=e.data.ACCESS_RIGHTS;t.userGroups=e.data.USER_GROUPS;t.loadData();t.draw()}t.unBlockGrid()}),(function(){return t.unBlockGrid}))}},{key:"blockGrid",value:function e(){var t=this;var s=this.layout.container.getBoundingClientRect().top<0?"0":this.layout.container.getBoundingClientRect().top;o.Dom.addClass(this.layout.container,"ui-access-rights-block");o.Dom.style(this.layout.container,"height","calc(100vh - "+s+"px)");setTimeout((function(){o.Dom.style(t.layout.container,"height","calc(100vh - "+s+"px)")}));this.getLoader().show()}},{key:"unBlockGrid",value:function e(){o.Dom.removeClass(this.layout.container,"ui-access-rights-block");o.Dom.style(this.layout.container,"height",null);this.getLoader().hide()}},{key:"getLoader",value:function e(){if(!this.loader){this.loader=new t.Loader({target:this.layout.container})}return this.loader}},{key:"removeRoleColumn",value:function e(t){this.headSection.removeColumn(t.data);this.accessRightsSections.map((function(e){e.removeColumn(t.data)}));var s=this.userGroups.indexOf(t.data.userGroup);this.userGroups.splice(s,1);var i=t.data.userGroup.id;if(i>0){this.deleteActionRequest(i)}}},{key:"addRoleColumn",value:function e(t){var s=t.getData(),i=babelHelpers.slicedToArray(s,1),r=i[0];if(!r){return}var n=this.accessRightsSections;for(var a=0;a<n.length;a++){r.headSection=false;r.newColumn=true;n[a].addColumn(r);n[a].scrollToRight(n[a].getColumnsContainer().scrollWidth-n[a].getColumnsContainer().offsetWidth,"stop")}r.headSection=true;r.newColumn=true;this.headSection.addColumn(r)}},{key:"addUserGroup",value:function e(t){var s=t.getData(),i=babelHelpers.slicedToArray(s,1),r=i[0];r=r||{};this.userGroups.push(r)}},{key:"updateRole",value:function e(t){var s=t.getData();var i=this.userGroups.indexOf(s.userGroup);if(i>=0){this.userGroups[i].title=s.text}}},{key:"adjustButtonPanel",value:function e(){var t=this.getMainContainer().querySelectorAll(".ui-access-rights-column-item-changer-on");var s=this.getMainContainer().querySelectorAll(".ui-access-rights-column-new");var i=this.getMainContainer().querySelectorAll(".ui-access-rights-members-item-new");var r=this.getMainContainer().querySelectorAll(".ui-tag-selector-container");if(t.length>0||s.length>0||i.length>0||r.length>0){this.buttonPanel.show()}else{this.buttonPanel.hide()}}},{key:"updateAccessRight",value:function e(t){var s=t.getData();var i=this.userGroups[this.userGroups.indexOf(s.userGroup)];var r=s.access.id;for(var n=0;n<i.accessRights.length;n++){var a=i.accessRights[n];if(a&&a.id===r){a.value=a.value==="0"?"1":"0";return}}i.accessRights.push({id:r,value:s.switcher.checked?"1":"0"})}},{key:"updateAccessVariationRight",value:function e(t){var s=t.getData();var i=this.userGroups[this.userGroups.indexOf(s.userGroup)];var r=s.access.id;var n=[];for(var a=0;a<i.accessRights.length;a++){var o=i.accessRights[a];if(o&&o.id===r){n.push(a)}}n.forEach((function(e){delete i.accessRights[e]}));var l=s.selectedValues||[];l.forEach((function(e){i.accessRights.push({id:r,value:e})}))}},{key:"loadData",value:function e(){var t=this;this.accessRights.map((function(e,s){e.id=s;t.accessRightsSections.push(t.addSection(e))}))}},{key:"getColumns",value:function e(){return this.columns}},{key:"getSections",value:function e(){return this.accessRightsSections}},{key:"getUserGroups",value:function e(){this.userGroups.forEach((function(e){if(e.accessCodes){for(var t in e.members){e.accessCodes[t]=e.members[t].type}}}));return this.userGroups}},{key:"getHeadSection",value:function e(){if(!this.headSection){this.headSection=new He({headSection:true,userGroups:this.userGroups,grid:this})}return this.headSection}},{key:"addSection",value:function e(t){t=t||{};return new He({id:t.id,hint:t.sectionHint,title:t.sectionTitle,rights:t.rights?t.rights:[],grid:this})}},{key:"getSectionNode",value:function e(){return o.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section'></div>"])))}},{key:"getMainContainer",value:function e(){if(!this.layout.container){this.layout.container=o.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights'></div>"])))}return this.layout.container}},{key:"draw",value:function e(){var t=document.createDocumentFragment();o.Dom.append(this.getHeadSection().render(),t);this.getSections().map((function(e){o.Dom.append(e.render(),t)}));this.layout.container=null;o.Dom.append(t,this.getMainContainer());this.renderTo.innerHTML="";o.Dom.append(this.getMainContainer(),this.renderTo);this.afterRender()}},{key:"afterRender",value:function e(){this.getHeadSection().adjustEars();this.getSections().map((function(e){e.adjustEars()}))}},{key:"onMemberSelect",value:function t(s){var i=e.buildOption(s);if(!i){return}if(s.state==="select"){n.EventEmitter.emit("BX.UI.AccessRights:addToAccessCodes",i)}}},{key:"onMemberUnselect",value:function t(s){var i=e.buildOption(s);if(!i){return}n.EventEmitter.emit("BX.UI.AccessRights:removeFromAccessCodes",i)}},{key:"onGetEntityTypes",value:function e(){var t=c.Main.selectorManagerV2.controls;var s=t[Object.keys(t)[0]];s.entityTypes.USERGROUPS={options:{enableSearch:"Y",searchById:"Y",addTab:"Y",returnItemUrl:s.getOption("returnItemUrl")==="N"?"N":"Y"}}}}],[{key:"buildOption",value:function e(t){var s=c.Main.selectorManagerV2.controls;var i=s[Object.keys(s)[0]].selectorInstance;var r="bx-data-column-id";var n=i.bindOptions.node;if(!n.hasAttribute(r)||o.Type.isUndefined(t.item)){return false}var a=n.getAttribute(r);var l=t.item.id;var u=t.entityType;var h={};h[l]=u;return{accessCodes:h,columnId:a,item:t.item}}}]);return e}();babelHelpers.defineProperty(h,"ACTION_SAVE","save");babelHelpers.defineProperty(h,"ACTION_DELETE","delete");babelHelpers.defineProperty(h,"ACTION_LOAD","load");babelHelpers.defineProperty(h,"MODE","ajax");var d=o.Reflection.namespace("BX.UI");d.AccessRights=h;var p;var g=function(){function e(t){babelHelpers.classCallCheck(this,e);this.currentValue=t.currentValue||null;this.identificator="col-"+Math.random();this.parentContainer=t.container;this.grid=t.grid;this.text=t.text;this.userGroup=t.userGroup;this.access=t.access;this.bindEvents()}babelHelpers.createClass(e,[{key:"bindEvents",value:function e(){}},{key:"render",value:function e(){return o.Tag.render(p||(p=babelHelpers.taggedTemplateLiteral(["<div></div>"])))}},{key:"getId",value:function e(){return this.identificator}}]);return e}();var m;var v=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"render",value:function e(){var t=this;var s=o.Tag.render(m||(m=babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div \n\t\t\t\tclass='ui-access-rights-column-item-text'\n\t\t\t\tdata-id='","'\n\t\t\t>\n\t\t\t\t","\n\t\t\t</div>\n\t\t"])),this.getId(),o.Text.encode(this.text));o.Event.bind(s,"mouseenter",this.adjustPopupHelper.bind(this));o.Event.bind(s,"mouseleave",(function(){if(t.popupHelper){t.popupHelper.close()}}));return s}},{key:"adjustPopupHelper",value:function e(){var t=this.parentContainer.cloneNode(true);o.Dom.style(t,"position","absolute");o.Dom.style(t,"display","inline");o.Dom.style(t,"visibility","hidden");o.Dom.style(t,"height","0");o.Dom.append(t,document.body);setTimeout((function(){o.Dom.remove(t)}));if(t.offsetWidth>this.parentContainer.offsetWidth){o.Dom.style(t,"visibility","visible");this.getPopupHelper().show()}}},{key:"getPopupHelper",value:function e(){if(!this.popupHelper){this.popupHelper=r.PopupWindowManager.create(null,this.parentContainer,{autoHide:true,darkMode:true,content:this.text,maxWidth:this.parentContainer.offsetWidth,offsetTop:-9,offsetLeft:5,animation:"fading-slide"})}return this.popupHelper}}]);return t}(g);babelHelpers.defineProperty(v,"TYPE","title");var b;var f=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.hint=e.hint;s.className=e.className;s.hintNode=null;return s}babelHelpers.createClass(t,[{key:"render",value:function e(){if(!this.hintNode&&this.hint){var t=BX.UI.Hint.createInstance({id:"access-rights-ui-hint-"+this.getId(),popupParameters:{className:"ui-access-rights-popup-pointer-events ui-hint-popup",autoHide:true,darkMode:true,maxWidth:280,offsetTop:0,offsetLeft:8,angle:true,animation:"fading-slide"}});this.hintNode=o.Tag.render(b||(b=babelHelpers.taggedTemplateLiteral(["<span class='","'></span>"])),this.className);this.hintNode.setAttribute(t.attributeName,this.hint);this.hintNode.setAttribute(t.attributeHtmlName,true);this.hintNode.setAttribute(t.attributeInteractivityName,true);t.initNode(this.hintNode)}return this.hintNode}}]);return t}(g);var C,y,E,T,S,R,I,k,H,A,D,P,G,L,U,M,w,_,B,O;var x=o.Reflection.namespace("BX");var X=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.openPopupEvent=e.openPopupEvent;s.popupContainer=e.popupContainer;s.accessCodes=e.accessCodes||[];return s}babelHelpers.createClass(t,[{key:"bindEvents",value:function e(){n.EventEmitter.subscribe("BX.UI.AccessRights:addToAccessCodes",this.addToAccessCodes.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:removeFromAccessCodes",this.removeFromAccessCodes.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:reset",this.resetNewMembers.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:refresh",this.resetNewMembers.bind(this))}},{key:"getMember",value:function e(){if(!this.member){var t=this.userGroup.members||{};var s=document.createDocumentFragment();var i=0;this.validateVariables();Object.keys(t).reverse().forEach((function(e){i++;if(i<7){var r=t[e];var n=o.Tag.render(C||(C=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t\t\t<div class='ui-access-rights-members-item'></div>\n\t\t\t\t\t\t"])));if(r["new"]){o.Dom.addClass(n,"ui-access-rights-members-item-new")}if(r.avatar){var a=o.Tag.render(y||(y=babelHelpers.taggedTemplateLiteral(["<a class='ui-access-rights-members-item-avatar' title=\"",'"></a>'])),o.Text.encode(r.name));o.Dom.style(a,"backgroundImage","url('"+encodeURI(r.avatar)+"')");o.Dom.style(a,"backgroundSize","cover");o.Dom.append(a,n)}else{var l="ui-icon-common-user";if(r.type==="groups"){l="ui-icon-common-user-group"}else if(r.type==="sonetgroups"){l="ui-icon-common-company"}else if(r.type==="usergroups"){l="ui-icon-common-user-group"}var u=o.Tag.render(E||(E=babelHelpers.taggedTemplateLiteral(["<a class='ui-icon ui-icon-xs' title=\"",'"><i></i></a>'])),o.Text.encode(r.name));o.Dom.addClass(u,l);o.Dom.append(u,n)}o.Dom.append(n,s)}}));o.Dom.append(this.getAddUserToRole(),s);this.member=o.Tag.render(T||(T=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-members'>","</div>"])),s);o.Event.bind(this.member,"click",this.adjustPopupUserControl.bind(this))}return this.member}},{key:"render",value:function e(){return this.getMember()}},{key:"resetNewMembers",value:function e(){var t=this.getMember().querySelectorAll(".ui-access-rights-members-item-new");t.forEach((function(e){o.Dom.removeClass(e,"ui-access-rights-members-item-new")}))}},{key:"validateVariables",value:function e(){if(o.Type.isUndefined(this.userGroup.accessCodes)){this.userGroup.accessCodes=[]}}},{key:"updateMembers",value:function e(){o.Dom.remove(this.member);this.member=null;o.Dom.append(this.getMember(),this.parentContainer);this.grid.getButtonPanel().show()}},{key:"addToAccessCodes",value:function e(t){var s=t.getData();if(s.columnId!==this.getId()){return}var i=Object.keys(s.accessCodes)[0];var r=s.accessCodes[i].toUpperCase();this.userGroup.accessCodes=Object.keys(this.accessCodes);var n=s.item;if(!o.Type.isUndefined(n)&&Object.keys(n).length){this.userGroup.members[i]={id:n.entityId,name:n.name,avatar:n.avatar,url:"",new:true,type:r.toLowerCase()};this.updateMembers()}this.userGroup.accessCodes=[];for(var a in this.userGroup.members){this.userGroup.accessCodes[a]=this.userGroup.members[a].type}}},{key:"removeFromAccessCodes",value:function e(t){var s=t.data;if(s.columnId!==this.identificator){return}var i=Object.keys(s.accessCodes)[0];delete this.userGroup.members[i];this.updateMembers();this.userGroup.accessCodes=[];for(var r in this.userGroup.members){this.userGroup.accessCodes[r]=this.userGroup.members[r].type}}},{key:"adjustPopupUserControl",value:function e(){var t=[];var s=[];var i=[];var r=[];for(var n in this.userGroup.members){this.userGroup.members[n].key=n;if(this.userGroup.members[n].type==="users"){t.push(this.userGroup.members[n])}else if(this.userGroup.members[n].type==="groups"){s.push(this.userGroup.members[n])}else if(this.userGroup.members[n].type==="usergroups"){s.push(this.userGroup.members[n])}else if(this.userGroup.members[n].type==="departments"){i.push(this.userGroup.members[n])}else if(this.userGroup.members[n].type==="sonetgroups"){r.push(this.userGroup.members[n])}}var a=[];for(var o in this.userGroup.members){a.push(this.userGroup.members[o])}if(a.length===0){this.showUserSelectorPopup();return}this.getUserPopup(t,s,i,r).show()}},{key:"getAddUserToRole",value:function e(){if(!this.addUserToRole){this.addUserToRole=o.Tag.render(S||(S=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span \n\t\t\t\t\tclass='ui-access-rights-members-item ui-access-rights-members-item-add'\n\t\t\t\t\tbx-data-column-id='","'\n\t\t\t\t>\n\t\t\t\t</span>\n\t\t\t"])),this.getId())}return this.addUserToRole}},{key:"getUserPopup",value:function e(t,s,i,n){var a=this;if(!this.popupUsers){t=t||[];s=s||[];i=i||[];n=n||[];var l=o.Tag.render(R||(R=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler'></div>"])));var u=o.Tag.render(I||(I=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-title'></div>"])));var c=function e(t){var s=t.target;f(s);b(s)};if(s.length>0){var h=o.Tag.render(k||(k=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass='ui-access-rights-popup-toggler-title-item ui-access-rights-popup-toggler-title-item-active'\n\t\t\t\t\t\tdata-role='ui-access-rights-popup-toggler-content-groups'\n\t\t\t\t\t>\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_USER_GROUPS"));o.Event.bind(h,"click",c.bind(this));o.Dom.append(h,u)}if(i.length>0){var d=o.Tag.render(H||(H=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass='ui-access-rights-popup-toggler-title-item'\n\t\t\t\t\t\tdata-role='ui-access-rights-popup-toggler-content-departments'\n\t\t\t\t\t>\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_DEPARTMENTS"));o.Event.bind(d,"click",c.bind(this));o.Dom.append(d,u)}if(t.length>0){var p=o.Tag.render(A||(A=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass='ui-access-rights-popup-toggler-title-item'\n\t\t\t\t\t\tdata-role='ui-access-rights-popup-toggler-content-users'\n\t\t\t\t\t>\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_STAFF"));o.Event.bind(p,"click",c.bind(this));o.Dom.append(p,u)}if(n.length>0){var g=o.Tag.render(D||(D=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass='ui-access-rights-popup-toggler-title-item'\n\t\t\t\t\t\tdata-role='ui-access-rights-popup-toggler-content-sonetgroups'\n\t\t\t\t\t>\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_SOCNETGROUP"));o.Event.bind(g,"click",c.bind(this));o.Dom.append(g,u)}o.Dom.append(o.Tag.render(P||(P=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-title-slicker'></div>"]))),u);o.Dom.append(u,l);if(s.length>0){o.Dom.append(this.getUserPopupTogglerGroup(s,"groups"),l)}if(i.length>0){o.Dom.append(this.getUserPopupTogglerGroup(i,"departments"),l)}if(t.length>0){o.Dom.append(this.getUserPopupTogglerGroup(t,"users"),l)}if(n.length>0){o.Dom.append(this.getUserPopupTogglerGroup(n,"sonetgroups"),l)}var m=o.Tag.render(G||(G=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-footer'></div>"])));var v=o.Tag.render(L||(L=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-popup-toggler-footer-link'>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ADD"));o.Event.bind(v,"click",(function(e){a.popupUsers.close();a.showUserSelectorPopup();e.preventDefault()}));o.Dom.append(v,m);o.Dom.append(m,l);var b=function e(t){if(!o.Type.isDomNode(t)){t=l.querySelector(".ui-access-rights-popup-toggler-title-item-active")}var s=l.querySelector(".ui-access-rights-popup-toggler-title-slicker");o.Dom.style(s,"left",t.offsetLeft+"px");o.Dom.style(s,"width",t.offsetWidth+"px")};var f=function e(t){var s=l.querySelectorAll(".ui-access-rights-popup-toggler-title-item");var i=l.querySelectorAll(".ui-access-rights-popup-toggler-content");var r=l.querySelector("."+t.getAttribute("data-role"));s.forEach((function(e){o.Dom.removeClass(e,"ui-access-rights-popup-toggler-title-item-active")}));i.forEach((function(e){o.Dom.style(e,"display","none")}));o.Dom.style(r,"display","block");o.Dom.addClass(t,"ui-access-rights-popup-toggler-title-item-active")};this.popupUsers=r.PopupWindowManager.create(null,this.getAddUserToRole(),{contentPadding:10,animation:"fading-slide",content:l,padding:0,offsetTop:5,angle:{position:"top",offset:35},autoHide:true,closeEsc:true,events:{onPopupShow:function e(){setTimeout((function(){var e=l.querySelector(".ui-access-rights-popup-toggler-title-item");if(!e){return}o.Dom.addClass(e,"ui-access-rights-popup-toggler-title-item-active");b(e)}))},onPopupClose:function e(){a.popupUsers.destroy();a.popupUsers=null}}})}return this.popupUsers}},{key:"getUserPopupTogglerGroup",value:function e(t,s){var i=this;var r=o.Tag.render(U||(U=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-content'></div>"])));o.Dom.addClass(r,"ui-access-rights-popup-toggler-content-"+s);t.forEach((function(e){var t=o.Tag.render(M||(M=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-content-item'></div>"])));if(e.avatar){var n=o.Tag.render(w||(w=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<a \n\t\t\t\t\t\tclass='ui-access-rights-popup-toggler-content-item-userpic'\n\t\t\t\t\t\ttitle=\"",'"\n\t\t\t\t\t></a>\n\t\t\t\t'])),o.Text.encode(e.name));o.Dom.style(n,"backgroundImage","url('"+encodeURI(e.avatar)+"')");o.Dom.style(n,"backgroundSize","cover");o.Dom.append(n,t)}else{var a="";if(s==="users"){a="ui-icon-common-user"}else if(s==="groups"){a="ui-icon-common-user-group"}else if(s==="sonetgroups"||s==="departments"){a="ui-icon-common-company"}var l=o.Tag.render(_||(_=babelHelpers.taggedTemplateLiteral(["<a class='ui-icon ui-icon-sm' title=\"",'"><i></i></a>'])),o.Text.encode(e.name));o.Dom.addClass(l,a);o.Dom.style(l,"margin","5px 10px");o.Dom.append(l,t)}o.Dom.append(o.Tag.render(B||(B=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-popup-toggler-content-item-name'>","</div>"])),o.Text.encode(e.name)),t);var u=o.Tag.render(O||(O=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-popup-toggler-content-item-remove'>","</div>\n\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_REMOVE"));o.Event.bind(u,"click",(function(){i.userGroup.accessCodes.splice(i.userGroup.accessCodes.indexOf(e.key),1);delete i.userGroup.accessCodes[e.key];delete i.userGroup.members[e.key];o.Dom.remove(t);i.updateMembers();i.adjustPopupUserControl();i.grid.getButtonPanel().show()}));o.Dom.append(u,t);o.Dom.append(t,r)}));return r}},{key:"showUserSelectorPopup",value:function e(){var t;var s=(t=x.Main.selectorManagerV2.controls[this.popupContainer])===null||t===void 0?void 0:t.selectorInstance;if(s){s.itemsSelected={}}x.onCustomEvent(this.openPopupEvent,[{id:this.popupContainer,bindNode:this.getAddUserToRole()}]);x.onCustomEvent("BX.Main.SelectorV2:reInitDialog",[{selectorId:this.popupContainer,selectedItems:this.userGroup.accessCodes}])}}]);return t}(g);babelHelpers.defineProperty(X,"TYPE","members");var N,V,j,Y,q,J;var W=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.column=e.column;return s}babelHelpers.createClass(t,[{key:"bindEvents",value:function e(){var t=this;o.Event.bind(window,"click",(function(e){if(e.target===t.getRole()||e.target.closest(".ui-access-rights-role")){return}t.updateRole();t.offRoleEditMode()}));n.EventEmitter.subscribe(this.grid,"onBeforeSave",(function(){t.updateRole();t.offRoleEditMode()}))}},{key:"getRole",value:function e(){var t=this;if(this.role){return this.role}n.EventEmitter.subscribe("BX.UI.AccessRights:preservation",this.updateRole.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:preservation",this.offRoleEditMode.bind(this));this.roleInput=o.Tag.render(N||(N=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<input\n\t\t\t\t\ttype='text'\n\t\t\t\t\tclass='ui-access-rights-role-input'\n\t\t\t\t\tvalue='","'\n\t\t\t\t\tplaceholder='","'\n\t\t\t\t/>\n\t\t\t"])),o.Text.encode(this.text),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ROLE_NAME"));o.Event.bind(this.roleInput,"keydown",(function(e){if(e.keyCode===13){t.updateRole();t.offRoleEditMode()}}));o.Event.bind(this.roleInput,"input",(function(){t.grid.getButtonPanel().show()}));this.roleValue=o.Tag.render(V||(V=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-role-value'>","</div>"])),o.Text.encode(this.text));var s=o.Tag.render(j||(j=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-role-edit'></div>"])));o.Event.bind(s,"click",this.onRoleEditMode.bind(this));var i=o.Tag.render(Y||(Y=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-role-remove'></div>"])));o.Event.bind(i,"click",this.showPopupConfirm.bind(this));var r=o.Tag.render(q||(q=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-role-controls'>\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),s,i);this.role=o.Tag.render(J||(J=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-role'>\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),this.roleInput,this.roleValue,r);return this.role}},{key:"render",value:function e(){return this.getRole()}},{key:"onRoleEditMode",value:function e(){o.Dom.addClass(this.getRole(),"ui-access-rights-role-edit-mode");this.roleInput.focus()}},{key:"showPopupConfirm",value:function e(){var t=this;if(!this.popupConfirm){this.popupConfirm=r.PopupWindowManager.create(null,this.getRole(),{width:250,overlay:true,contentPadding:10,content:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_POPUP_REMOVE_THIS_ROLE"),animation:"fading-slide"});this.popupConfirm.setButtons([new BX.UI.Button({text:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_POPUP_REMOVE"),className:"ui-btn ui-btn-sm ui-btn-primary",events:{click:function e(){t.popupConfirm.close();n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:removeRole",t)}}}),new BX.UI.Button({text:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_POPUP_CANCEL"),className:"ui-btn ui-btn-sm ui-btn-link",events:{click:function e(){t.popupConfirm.close()}}})])}this.popupConfirm.show()}},{key:"updateRole",value:function e(){if(this.roleValue.innerHTML===this.roleInput.value||this.roleInput.value===""){return}this.text=this.roleInput.value;this.userGroup=this.column.getUserGroup();this.roleValue.innerText=this.roleInput.value;n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:updateRole",this)}},{key:"offRoleEditMode",value:function e(){o.Dom.removeClass(this.getRole(),"ui-access-rights-role-edit-mode")}}]);return t}(g);babelHelpers.defineProperty(W,"TYPE","role");var F;var z=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.isModify=false;return s}babelHelpers.createClass(t,[{key:"getChanger",value:function e(){if(!this.changer){this.changer=o.Tag.render(F||(F=babelHelpers.taggedTemplateLiteral(["<a class='ui-access-rights-column-item-changer'></a>"])))}return this.changer}},{key:"bindEvents",value:function e(){n.EventEmitter.subscribe("BX.UI.AccessRights:reset",this.offChanger.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:refresh",this.refreshStatus.bind(this))}},{key:"refreshStatus",value:function e(){o.Dom.removeClass(this.getChanger(),"ui-access-rights-column-item-changer-on")}},{key:"offChanger",value:function e(){var t=this;if(this.isModify){setTimeout((function(){t.refreshStatus()}))}}},{key:"adjustChanger",value:function e(){this.isModify=!this.isModify;o.Dom.toggleClass(this.getChanger(),"ui-access-rights-column-item-changer-on")}}]);return t}(g);var K=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.switcher=new BX.UI.Switcher({size:"small",checked:s.currentValue==="1",handlers:{checked:function e(){n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:accessOn",babelHelpers.assertThisInitialized(s))},unchecked:function e(){n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:accessOff",babelHelpers.assertThisInitialized(s))},toggled:function e(){s.adjustChanger();n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:update",babelHelpers.assertThisInitialized(s))}}});return s}babelHelpers.createClass(t,[{key:"offChanger",value:function e(){if(this.isModify){this.switcher.check(!this.switcher.isChecked())}babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"offChanger",this).call(this)}},{key:"render",value:function e(){o.Dom.append(this.switcher.getNode(),this.getChanger());return this.getChanger()}}]);return t}(z);babelHelpers.defineProperty(K,"TYPE","toggler");var Q,Z,$;var ee=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"render",value:function e(){var t=this;if(!this.controller){this.controllerLink=o.Tag.render(Q||(Q=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-column-item-controller-link'>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_CREATE_ROLE"));this.controllerMenu=o.Tag.render(Z||(Z=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-column-item-controller-link'>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_COPY_ROLE"));o.Event.bind(this.controllerMenu,"click",(function(){if(t.popupMenu){t.popupMenu.close()}else if(t.grid.getUserGroups().length>0){t.getPopupMenu(t.grid.getUserGroups()).show()}}));this.toggleControllerMenu();this.controller=o.Tag.render($||($=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-column-item-controller'>\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),this.controllerLink,this.controllerMenu);o.Event.bind(this.controllerLink,"click",(function(){n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:addRole",[{id:"0",title:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ROLE_NAME"),accessRights:[],members:[],accessCodes:[],type:W.TYPE}]);n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:update",t);t.toggleControllerMenu();t.grid.lock()}));n.EventEmitter.subscribe("BX.UI.AccessRights.ColumnItem:removeRole",this.toggleControllerMenu.bind(this))}return this.controller}},{key:"getPopupMenu",value:function e(t){var s=this;if(!t){return}var i=[];t.map((function(e){i.push({text:o.Text.encode(e.title),onclick:function t(){var i=Object.assign([],e.accessRights);var r=Object.assign([],e.accessCodes);n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:copyRole",[{id:"0",title:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ROLE_NAME"),accessRights:i,accessCodes:r,type:W.TYPE,members:e.members}]);n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:update",s);s.popupMenu.destroy()}})}));return this.popupMenu=new r.Menu("ui_accessrights_copy_role_list",this.controllerMenu,i,{events:{onPopupClose:function e(){s.popupMenu.destroy();s.popupMenu=null}}})}},{key:"toggleControllerMenu",value:function e(){if(this.grid.getUserGroups().length===0){o.Dom.addClass(this.controllerMenu,"ui-access-rights-column-item-controller-link--disabled")}else{o.Dom.removeClass(this.controllerMenu,"ui-access-rights-column-item-controller-link--disabled")}}}]);return t}(g);var te;var se=function(e){babelHelpers.inherits(t,e);function t(e){var s;babelHelpers.classCallCheck(this,t);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));s.selectedValues=[s.currentValue];s.variables=e.variables||[];return s}babelHelpers.createClass(t,[{key:"bindEvents",value:function e(){n.EventEmitter.subscribe("BX.UI.AccessRights:reset",this.reset.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:refresh",this.refresh.bind(this))}},{key:"render",value:function e(){var t,s;var i=(t=(s=this.getSelected())===null||s===void 0?void 0:s.title)!==null&&t!==void 0?t:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ADD");var r=o.Tag.render(te||(te=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-column-item-text-link'>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),o.Text.encode(i));o.Event.bind(r,"click",this.showVariablesPopup.bind(this));o.Dom.append(r,this.getChanger());return this.getChanger()}},{key:"refresh",value:function e(){if(this.isModify){this.currentValue=this.selectedValues[0];this.reset()}}},{key:"reset",value:function e(){if(this.isModify){this.selectedValues=[this.currentValue];this.getChanger().innerHTML="";this.adjustChanger();this.render()}}},{key:"getSelected",value:function e(){var t=this;var s=this.variables.filter((function(e){return t.selectedValues.includes(e.id)}));return s[0]}},{key:"showVariablesPopup",value:function e(t){var s=this;var i=[];this.variables.map((function(e){i.push({id:e.id,text:e.title,onclick:s.select.bind(s)})}));r.PopupMenu.show("ui-access-rights-column-item-popup-variables",t.target,i,{autoHide:true,events:{onPopupClose:function e(){r.PopupMenu.destroy("ui-access-rights-column-item-popup-variables")}}})}},{key:"select",value:function e(t,s){var i;this.selectedValues=[s.id];(i=s.getMenuWindow())===null||i===void 0?void 0:i.close();this.getChanger().innerHTML="";this.render();this.adjustChanger();n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:selectAccessItems",this);n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:update",this)}}]);return t}(z);babelHelpers.defineProperty(se,"TYPE","variables");var ie;var re=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}babelHelpers.createClass(t,[{key:"render",value:function e(){return o.Tag.render(ie||(ie=babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div \n\t\t\t\tclass='ui-access-rights-column-item-text'\n\t\t\t\tdata-id='","'\n\t\t\t>\n\t\t\t\t","\n\t\t\t</div>\n\t\t"])),this.getId(),o.Text.encode(this.text))}}]);return t}(v);babelHelpers.defineProperty(re,"TYPE","userGroupTitle");var ne,ae,oe;var le=function(e){babelHelpers.inherits(t,e);function t(e,s){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e,s));i.selectAllButton=o.Tag.render(ne||(ne=babelHelpers.taggedTemplateLiteral(['<div class="ui-selector-footer-link ui-selector-search-footer-label--hide">',"</div>"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ALL_SELECT_LABEL"));o.Event.bind(i.selectAllButton,"click",i.selectAll.bind(babelHelpers.assertThisInitialized(i)));i.deselectAllButton=o.Tag.render(ae||(ae=babelHelpers.taggedTemplateLiteral(['<div class="ui-selector-footer-link ui-selector-search-footer-label--hide">',"</div>"])),o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ALL_DESELECT_LABEL"));o.Event.bind(i.deselectAllButton,"click",i.deselectAll.bind(babelHelpers.assertThisInitialized(i)));i.getDialog().subscribe("Item:onSelect",i.onItemStatusChange.bind(babelHelpers.assertThisInitialized(i)));i.getDialog().subscribe("Item:onDeselect",i.onItemStatusChange.bind(babelHelpers.assertThisInitialized(i)));return i}babelHelpers.createClass(t,[{key:"getContent",value:function e(){this.toggleSelectButtons();return o.Tag.render(oe||(oe=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<div class="ui-selector-search-footer-box">\n\t\t\t\t',"\n\t\t\t\t","\n\t\t\t</div>\n\t\t"])),this.selectAllButton,this.deselectAllButton)}},{key:"toggleSelectButtons",value:function e(){if(this.getDialog().getSelectedItems().length===this.getDialog().getItems().length){if(o.Dom.hasClass(this.deselectAllButton,"ui-selector-search-footer-label--hide")){o.Dom.addClass(this.selectAllButton,"ui-selector-search-footer-label--hide");o.Dom.removeClass(this.deselectAllButton,"ui-selector-search-footer-label--hide")}}else if(o.Dom.hasClass(this.selectAllButton,"ui-selector-search-footer-label--hide")){o.Dom.addClass(this.deselectAllButton,"ui-selector-search-footer-label--hide");o.Dom.removeClass(this.selectAllButton,"ui-selector-search-footer-label--hide")}}},{key:"selectAll",value:function e(){if(this.getDialog().getSelectedItems().length===this.getDialog().getItems().length){return}this.getDialog().getItems().forEach((function(e){e.select()}))}},{key:"deselectAll",value:function e(){this.getDialog().getSelectedItems().forEach((function(e){e.deselect()}))}},{key:"onItemStatusChange",value:function e(){this.toggleSelectButtons()}}]);return t}(a.DefaultFooter);var ue;var ce=function(e){babelHelpers.inherits(t,e);function t(e){var s,i,r;var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));n.variables=e.variables||[];n.enableSearch=(s=e.enableSearch)!==null&&s!==void 0?s:false;n.placeholder=e.placeholder||"";n.hintTitle=e.hintTitle||"";n.allSelectedCode=o.Text.toNumber(e.allSelectedCode||-1);n.showAvatars=(i=e.showAvatars)!==null&&i!==void 0?i:true;n.compactView=(r=e.compactView)!==null&&r!==void 0?r:false;n.currentValue=o.Type.isArray(e.currentValue)?e.currentValue:[];n.currentValue=n.currentValue.map((function(e){return o.Text.toNumber(e)}));n.selectedValues=n.currentValue;n.variables=n.variables.map((function(e){e.entityId=e.entityId||"editor-right-item";e.tabs="recents";return e}));n.selector=n.createSelector();return n}babelHelpers.createClass(t,[{key:"bindEvents",value:function e(){n.EventEmitter.subscribe("BX.UI.AccessRights:reset",this.reset.bind(this));n.EventEmitter.subscribe("BX.UI.AccessRights:refresh",this.refresh.bind(this))}},{key:"createSelector",value:function e(){return new a.Dialog({height:300,id:this.getId(),context:"editor-right-items",enableSearch:this.enableSearch,multiple:true,dropdownMode:true,compactView:this.compactView,showAvatars:this.showAvatars,selectedItems:this.getSelected(),searchOptions:{allowCreateItem:false},events:{"Item:onSelect":this.setSelectedInputs.bind(this),"Item:onDeselect":this.setSelectedInputs.bind(this)},entities:[{id:"editor-right-item"}],items:this.variables,footer:le})}},{key:"render",value:function e(){var t="";if(this.includesSelected(this.allSelectedCode)){t=o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ALL_ACCEPTED")}else{var s;var i=[];(s=this.getSelected())===null||s===void 0?void 0:s.forEach((function(e){i.push(e.title)}));if(i.length>0){var r=i[0];t=i.length-1>0?o.Loc.getMessage("JS_UI_ACCESSRIGHTS_HAS_SELECTED_ITEMS",{"#FIRST_ITEM_NAME#":r.length>10?r.slice(0,10)+"...":r,"#COUNT_REST_ITEMS#":i.length-1}):r}else{t=o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ADD")}}var n="";if(this.selector.getSelectedItems().length>0){var a=o.Type.isStringFilled(this.hintTitle)?this.hintTitle:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_SELECTED_ITEMS_TITLE");n+="<p>"+a+":</p>";n+="<ul>";this.selector.getSelectedItems().forEach((function(e){return n+="<li>"+o.Text.encode(e.getTitle())}));n+="</ul>"}var l=o.Tag.render(ue||(ue=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-column-item-text-link' data-hint-html data-hint-no-icon data-hint=\"",'">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),o.Text.encode(n),o.Text.encode(t));o.Event.bind(l,"click",this.showSelector.bind(this));o.Dom.append(l,this.getChanger());BX.UI.Hint.init(this.getChanger());return this.getChanger()}},{key:"refresh",value:function e(){if(this.isModify){this.currentValue=this.selectedValues;this.reset()}}},{key:"reset",value:function e(){if(this.isModify){this.selectedValues=this.currentValue;this.selector=this.createSelector();this.getChanger().innerHTML="";this.adjustChanger();this.render()}}},{key:"getSelected",value:function e(){var t=this;if(this.includesSelected(this.allSelectedCode)){return this.variables}return this.variables.filter((function(e){return t.includesSelected(e.id)}))}},{key:"includesSelected",value:function e(t){return this.selectedValues.includes(o.Text.toNumber(t))}},{key:"showSelector",value:function e(t){this.selector.show()}},{key:"setSelectedInputs",value:function e(){var t=this;var s=this.selector.getSelectedItems();this.selectedValues=[];if(s.length===this.variables.length){this.selectedValues.push(this.allSelectedCode)}else{s.forEach((function(e){t.selectedValues.push(o.Text.toNumber(e.id))}))}this.getChanger().innerHTML="";if(!this.isModify){this.adjustChanger()}this.render();n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:update",this);n.EventEmitter.emit("BX.UI.AccessRights.ColumnItem:selectAccessItems",this)}}]);return t}(z);babelHelpers.defineProperty(ce,"TYPE","multivariables");var he;function de(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,i)}return s}function pe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?de(Object(s),!0).forEach((function(t){babelHelpers.defineProperty(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):de(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var ge=function(){function e(t){babelHelpers.classCallCheck(this,e);this.options=t;this.type=t.type?t.type:null;this.hint=t.hint?t.hint:null;this.controller=t.controller?t.controller:null;this.column=t.column}babelHelpers.createClass(e,[{key:"render",value:function e(){var t=null;var s=o.Tag.render(he||(he=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-column-item'></div>"])));this.options.container=s;if(this.type===W.TYPE){t=new W(this.options);if(this.column.newColumn){setTimeout((function(){t.onRoleEditMode();t.roleInput.value=""}))}}else if(this.type===X.TYPE){t=new X(this.options)}else if(this.type===v.TYPE){t=new v(this.options)}else if(this.type===se.TYPE){t=new se(this.options)}else if(this.type===ce.TYPE){t=new ce(this.options)}else if(this.type===K.TYPE){t=new K(this.options)}if(t){o.Dom.append(t.render(),s)}if(this.hint){var i=pe({className:"ui-access-rights-column-item-notify"},this.options);o.Dom.append(new f(i).render(),s)}if(this.type===re.TYPE){o.Dom.append(new re(this.options).render(),s)}if(this.controller){o.Dom.append(new ee(this.options).render(),s)}return s}}]);return e}();var me=o.Reflection.namespace("BX.UI.AccessRights");me.ColumnItem=ge;var ve;var be=function(){function e(t){babelHelpers.classCallCheck(this,e);this.layout={container:null};this.grid=t.grid?t.grid:null;this.items=t.items?t.items:[];this.userGroup=t.userGroup?t.userGroup:null;this.accessCodes=t.accessCodes?t.accessCodes:null;this.section=t.section?t.section:null;this.headSection=t.headSection;this.newColumn=t.newColumn?t.newColumn:null;this.openPopupEvent=t.grid.openPopupEvent?t.grid.openPopupEvent:null;this.popupContainer=t.grid.popupContainer?t.grid.popupContainer:null}babelHelpers.createClass(e,[{key:"getItem",value:function e(t){t=t||{};var s={};if(t.type===re.TYPE){s={type:t.type,text:t.title,controller:t.controller}}if(t.type===v.TYPE){s={id:t.id,type:t.type,hint:t.hint,text:t.title,controller:t.controller}}if(t.type===K.TYPE){s={type:t.type,access:t.access}}if(t.type===se.TYPE||t.type===ce.TYPE){s={type:t.type,text:t.title,variables:t.variables,access:t.access}}if(t.type===ce.TYPE){s.allSelectedCode=t.allSelectedCode;s.enableSearch=t.enableSearch;s.showAvatars=t.showAvatars;s.compactView=t.compactView;s.hintTitle=t.hintTitle}if(t.type===W.TYPE){s={type:t.type,text:t.title}}if(t.type===X.TYPE){var i=[];for(var r in t.members){i[r]=t.members[r].type}s={type:t.type,accessCodes:i}}s.column=this;s.userGroup=this.userGroup;s.openPopupEvent=this.openPopupEvent;s.popupContainer=this.popupContainer;s.currentValue=null;s.grid=this.grid;if(t.type===se.TYPE||t.type===ce.TYPE||t.type===K.TYPE){var n,a;var o=s.access.id.toString();var l=(n=(a=s.userGroup)===null||a===void 0?void 0:a.accessRights)!==null&&n!==void 0?n:[];for(var u=0;u<l.length;u++){if(o===l[u].id.toString()){if(t.type===ce.TYPE){var c;s.currentValue=(c=s.currentValue)!==null&&c!==void 0?c:[];s.currentValue.push(l[u].value)}else{s.currentValue=l[u].value}}}}return new ge(s)}},{key:"getUserGroup",value:function e(){return this.userGroup}},{key:"remove",value:function e(){var t=this;if(o.Dom.hasClass(this.layout.container,"ui-access-rights-column-new")){this.resetClassNew()}o.Dom.addClass(this.layout.container,"ui-access-rights-column-remove");o.Dom.style(this.layout.container,"width",this.layout.container.offsetWidth+"px");o.Event.bind(this.layout.container,"animationend",(function(){o.Dom.style(t.layout.container,"minWidth","0px");o.Dom.style(t.layout.container,"maxWidth","0px")}));setTimeout((function(){o.Dom.remove(t.layout.container)}),500)}},{key:"resetClassNew",value:function e(){o.Dom.removeClass(this.layout.container,"ui-access-rights-column-new")}},{key:"render",value:function e(){var t=this;if(!this.layout.container){var s=document.createDocumentFragment();if(this.headSection){this.userGroup.type=W.TYPE;o.Dom.append(this.getItem(this.userGroup).render(),s);this.userGroup.type=X.TYPE;o.Dom.append(this.getItem(this.userGroup).render(),s)}this.items.map((function(e){var i=t.getItem(e);o.Dom.append(i.render(),s)}));this.layout.container=o.Tag.render(ve||(ve=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-column'></div>"])));if(this.newColumn){o.Dom.addClass("ui-access-rights-column-new",this.layout.container)}n.EventEmitter.subscribe("BX.UI.AccessRights:refresh",this.resetClassNew.bind(this));o.Dom.append(s,this.layout.container);return this.layout.container}}}]);return e}();var fe=o.Reflection.namespace("BX.UI.AccessRights");fe.Column=be;var Ce,ye,Ee,Te,Se,Re,Ie,ke;var He=function(){function e(t){var s;babelHelpers.classCallCheck(this,e);this.id=(s=t.id)!==null&&s!==void 0?s:null;this.headSection=t.headSection?t.headSection:null;this.title=t.title;this.hint=t.hint;this.rights=t.rights?t.rights:[];this.userGroups=t.userGroups?t.userGroups:[];this.grid=t.grid?t.grid:null;this.layout={title:null,headColumn:null,columns:null,content:null,earLeft:null,earRight:null};this.scroll=0;this.earTimer=null;this.earLeftTimer=null;this.earRightTimer=null;this.columns=[];this.bindEvents()}babelHelpers.createClass(e,[{key:"bindEvents",value:function e(){var t=this;n.EventEmitter.subscribe(this.grid,"AccessRights.Section:scroll",(function(e){var s=e.getData(),i=babelHelpers.slicedToArray(s,1),n=i[0];if(t.title!==n.title){t.getColumnsContainer().scrollLeft=n.getScroll()}n.adjustEars();r.PopupMenu.destroy("ui-access-rights-column-item-popup-variables")}));o.Event.bind(window,"resize",this.adjustEars.bind(this))}},{key:"getGrid",value:function e(){return this.grid}},{key:"addColumn",value:function e(t){if(!t){return}var s=Object.assign({},t);s.userGroup=t;var i=this.getColumn(s);o.Dom.append(i.render(),this.layout.columns);this.columns.push(i)}},{key:"getColumn",value:function e(t){var s=[];this.rights.map((function(e){var t=e.type===se.TYPE||e.type===ce.TYPE;s.push({type:e.type,title:t?e.title:null,hint:e.hint,variables:t?e.variables:[],enableSearch:t?e.enableSearch:null,showAvatars:t?e.showAvatars:false,compactView:t?e.compactView:false,hintTitle:t?e.hintTitle:null,allSelectedCode:t?e.allSelectedCode:null,access:e})}));return new be({items:s,userGroup:t.userGroup?t.userGroup:null,section:this,headSection:t.headSection,grid:this.grid,newColumn:t.newColumn?t.newColumn:null})}},{key:"removeColumn",value:function e(t){if(!t){return}for(var s=0;s<this.columns.length;s++){if(t.userGroup===this.columns[s].userGroup){this.columns[s].remove();break}}}},{key:"addHeadColumn",value:function e(){var t=[];if(!this.headSection){this.rights.map((function(e){t.push({id:e.id,type:v.TYPE,title:e.title,hint:e.hint})}))}if(this.headSection){t=[{type:re.TYPE,title:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_ROLES"),controller:true},{type:re.TYPE,title:o.Loc.getMessage("JS_UI_ACCESSRIGHTS_EMPLOYEES_AND_DEPARTMENTS"),controller:false}]}var s=new be({items:t,section:this,grid:this.grid});o.Dom.append(s.render(),this.layout.headColumn);return s}},{key:"getColumnsContainer",value:function e(){if(!this.layout.columns){var t=o.Tag.render(Ce||(Ce=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section-wrapper'></div>"])));o.Event.bind(t,"scroll",this.adjustScroll.bind(this));this.layout.columns=t}return this.layout.columns}},{key:"getTitleNode",value:function e(){var t=o.Tag.render(ye||(ye=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section-title'>","</div>"])),o.Text.encode(this.title));if(this.hint){var s=new f({hint:this.hint,className:"ui-access-rights-section-title-hint"});t.appendChild(s.render())}return t}},{key:"adjustScroll",value:function e(){if(o.Text.toNumber(this.scroll)!==o.Text.toNumber(this.getColumnsContainer().scrollLeft)){this.scroll=this.getColumnsContainer().scrollLeft;n.EventEmitter.emit(this.grid,"AccessRights.Section:scroll",[this])}}},{key:"adjustEars",value:function e(){var t=this.getColumnsContainer();var s=t.scrollLeft;var i=s>0;var r=t.scrollWidth>Math.round(s+t.offsetWidth);this.getContentContainer().classList[i?"add":"remove"]("ui-access-rights-section-ear-left-shown");this.getContentContainer().classList[r?"add":"remove"]("ui-access-rights-section-ear-right-shown")}},{key:"getContentContainer",value:function e(){if(!this.layout.content){this.layout.content=o.Tag.render(Ee||(Ee=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class='ui-access-rights-section-content'>\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),this.getColumnsContainer(),this.getEarLeft(),this.getEarRight())}return this.layout.content}},{key:"getEarLeft",value:function e(){var t=this;if(!this.layout.earLeft){this.layout.earLeft=o.Tag.render(Te||(Te=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section-ear-left'></div>"])));o.Event.bind(this.layout.earLeft,"mouseenter",(function(){t.stopAutoScroll();t.earLeftTimer=setTimeout((function(){t.scrollToLeft()}),110)}));o.Event.bind(this.layout.earLeft,"mouseleave",(function(){clearTimeout(t.earLeftTimer);t.stopAutoScroll()}))}return this.layout.earLeft}},{key:"getEarRight",value:function e(){var t=this;if(!this.layout.earRight){this.layout.earRight=o.Tag.render(Se||(Se=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section-ear-right'></div>"])));o.Event.bind(this.layout.earRight,"mouseenter",(function(){t.stopAutoScroll();t.earRightTimer=setTimeout((function(){t.scrollToRight()}),110)}));o.Event.bind(this.layout.earRight,"mouseleave",(function(){clearTimeout(t.earRightTimer);t.stopAutoScroll()}))}return this.layout.earRight}},{key:"scrollToRight",value:function e(t,s){var i=this;var r=t?2:20;this.earTimer=setInterval((function(){i.getColumnsContainer().scrollLeft+=10;if(t&&t<=i.getColumnsContainer().scrollLeft){i.stopAutoScroll()}}),r);if(s==="stop"){setTimeout((function(){i.stopAutoScroll();i.getGrid().unlock()}),t*2)}}},{key:"scrollToLeft",value:function e(){var t=this;this.earTimer=setInterval((function(){t.getColumnsContainer().scrollLeft-=10}),20)}},{key:"stopAutoScroll",value:function e(){clearInterval(this.earTimer)}},{key:"getScroll",value:function e(){return this.scroll}},{key:"render",value:function e(){var t;var s=this.title?this.getTitleNode():null;var i=o.Tag.render(Re||(Re=babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class='ui-access-rights-section'>\n\t\t\t\t","\n\t\t\t\t","\n\t\t\t</div>\n\t\t"])),s,this.getMainContainer());if(this.headSection){o.Dom.addClass(i,"ui-access-rights--head-section")}this.addHeadColumn();var r=document.createDocumentFragment();var n=(t=this.grid.getUserGroups())!==null&&t!==void 0?t:[];for(var a=0;a<n.length;a++){var l=this.getColumn({headSection:this.headSection?this.headSection:null,userGroup:n[a]});this.columns.push(l);o.Dom.append(l.render(),r)}o.Dom.append(r,this.getColumnsContainer());return i}},{key:"getMainContainer",value:function e(){this.layout.headColumn=o.Tag.render(Ie||(Ie=babelHelpers.taggedTemplateLiteral(["<div class='ui-access-rights-section-head'></div>"])));return o.Tag.render(ke||(ke=babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class='ui-access-rights-section-container'>\n\t\t\t\t","\n\t\t\t\t","\n\t\t\t</div>\n\t\t"])),this.layout.headColumn,this.getContentContainer())}}]);return e}();var Ae=o.Reflection.namespace("BX.UI.AccessRights");Ae.Section=He;e.Grid=h;e.Section=He;e.Column=be;e.ColumnItem=ge})(this.BX.UI=this.BX.UI||{},BX,BX,BX,BX.Main,BX.Event,BX.UI.EntitySelector,BX);
//# sourceMappingURL=accessrights.bundle.map.js